package com.example.treehole.ui.model

import androidx.compose.ui.graphics.vector.ImageVector


open class Post(
    val postId: Int,        // 帖子id
    val authorId: Int,      // 作者id
    val title: String,      // 帖子标题
    val content: String,    // 帖子内容
    val createDate: Long,         // 时间戳
    val tag: Int,              // 帖子标签
    val pic: List<String>,     // 图片列表，url
    var likeCount: Int,       // 点赞数目
    var commentCount: Int,    // 评论数目
    var favoriteCount: Int     // 收藏数目
)

open class PostInfo(
    postId: Int,
    authorId: Int,
    title: String,
    content: String,
    createDate: Long,
    tag: Int,
    pic: List<String>,
    likeCount: Int,
    commentCount: Int,
    favoriteCount: Int,
    var isLike: Boolean,    // 是否点赞
    var isFavorite: Boolean, // 是否收藏
    var isComment: Boolean, // 是否评论
    var commentName: String // 该帖子下用户的临时名
) : Post(
    postId,
    authorId,
    title,
    content,
    createDate,
    tag,
    pic,
    likeCount,
    commentCount,
    favoriteCount
)

open class Comment(
    val cmtId:Int,              // 评论id
    val cmtName:String,         // 评论昵称
    val postId: Int,            // 评论所在的帖子id
    val type:Int,               // 评论的类型 (对帖子的评论/对评论的评论)
    val cmtCmtId: Int,          // 评论所在的评论id（仅type为1时有效）
    val replyUserName: String,  // 回复的对象昵称（仅type为1时有效）
    val cmtTime: Long,          // 评论时间
    val cmtContent: String,     // 评论内容
    var cmtLikeCount:Int,       // 评论点赞数
    var isLike: Boolean         // 是否点赞评论
)

class CommentToPost(
    cmtId:Int,
    cmtName:String,
    postId: Int,
    type:Int,
    cmtCmtId: Int,
    replyUserName: String,
    cmtTime: Long,
    cmtContent: String,
    cmtLikeCount:Int,
    isLike: Boolean,
    val replyList: MutableList<Comment> = mutableListOf()
):Comment(cmtId, cmtName, postId, type, cmtCmtId, replyUserName, cmtTime, cmtContent, cmtLikeCount, isLike){
     companion object{
         fun fromComment(comment: Comment,replyList: MutableList<Comment> = mutableListOf()):CommentToPost{
             return CommentToPost(
                 comment.cmtId,
                 comment.cmtName,
                 comment.postId,
                 comment.type,
                 comment.cmtCmtId,
                 comment.replyUserName,
                 comment.cmtTime,
                 comment.cmtContent,
                 comment.cmtLikeCount,
                 comment.isLike,
                 replyList
             )
         }
     }
}

class PostDetail(
    postId: Int,
    authorId: Int,
    title: String,
    content: String,
    createDate: Long,
    tag: Int,
    pic: List<String>,
    likeCount: Int,
    commentCount: Int,
    favoriteCount: Int,
    isLike: Boolean,
    isFavorite: Boolean,
    isComment: Boolean,
    commentName: String,
    val authorName: String,
    val cmtList: MutableList<CommentToPost>
):PostInfo(postId, authorId, title, content, createDate, tag, pic, likeCount, commentCount, favoriteCount, isLike, isFavorite, isComment, commentName)

enum class InputCardType {
    EMAIL,
    PASSWORD,
    PASSWORD_AGAIN,
    VERIFY_CODE
}

enum class PostType {
    NO_TYPE,
    STUDY,
    LOVE,
    ENTERTAINMENT,
    GAME,
    SPORT,
    SCIENCE
}

enum class CommentType{
    CommentToPost,
    CommentToComment
}


data class TagSection(
    val type: PostType, // tag编号
    val title: String, // tag名称
    val icon: ImageVector? // icon
)

data class ApiResponse<T>(
    val code: Int,
    val msg: String,
    val data: T? = null
)

data class UserInfo(
    val userId: Int,
    val jwt: String
)